package com.cbgolf.oa.model;

import com.alibaba.fastjson.JSON;
import com.cbgolf.oa.entity.ChartBean;
import com.cbgolf.oa.entity.ListBean;
import com.cbgolf.oa.entity.NetResponse;
import com.cbgolf.oa.entity.PointBean;
import com.cbgolf.oa.entity.StatisticsBean;
import com.cbgolf.oa.net.NetCallBack;
import com.cbgolf.oa.net.NetUtils;
import com.cbgolf.oa.net.Web;
import com.cbgolf.oa.net.WebAPI;
import com.cbgolf.oa.presenter.IStatisticsPresenter;
import com.cbgolf.oa.util.TextUtil;
import com.cbgolf.oa.util.TypeUtil;
import com.cbgolf.oa.util.Util;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Created by lq on 2017/9/14.
 */

public class StatisticsModelImpl extends StatisticsModel {

  private List<PointBean> listPoint = new ArrayList<>();
  private List<StatisticsBean.outlet> listOutlet = new ArrayList<>();
//  private List<StatisticsBean.ChartData> listPayWay = new ArrayList<>();

  public StatisticsModelImpl(IStatisticsPresenter worker) {
    super(worker);
  }

  public void getPointList() {
    String url = WebAPI.outletList_get;
    Web.getOK(url, new NetCallBack(response -> doResult(response)));
  }

  private void doResult(NetResponse response) {
    if (NetUtils.SUCCESS != response.statusCode) {
      worker.getPointFail();
      return;
    }
    try {
      listPoint = JSON.parseArray(response.result, PointBean.class);
    } catch (Exception e) {
      worker.getPointFail();
      return;
    }
    worker.getPointSuccess(listPoint);
  }

  @Override
  public void getCaddieData(StatisticsBean m) {
    if (null != m.totalPlayTimes) {
      allTimes = m.totalPlayTimes.totalPlayTimes;
      allTimesCompare = m.totalPlayTimes.lastPercent;
    }
    if (null != m.averagePlayTimes) {
      meanTimes = m.averagePlayTimes.averagePlayTimes;
      timesCompare = m.averagePlayTimes.lastPercent;
    }
    if (null != m.averageTime) {
      meanDuration = TypeUtil.parseFloat(m.averageTime.averageTime) > 0 ?
          TextUtil.getDoubleFormat(String.valueOf(
              TypeUtil.parseFloat(m.averageTime.averageTime) / (1000 * 60)), 2)
          : "0.0";
      durationCompare = m.averageTime.lastPercent;
    }
    listTimes = m.playTimesCurves;
    listTimesLast = m.lastPlayTimesCurves;
    listBarThis = m.levelHistograms;
    listBarLast = m.lastLevelHistograms;
    listTimesMax.clear();
    if (null != listTimes && listTimes.size() > 0) {
      for (int i = 0; i < listTimes.size(); i++) {
        switch (dateType) {
          case CUR:
          case DAY:
          case WEEK:
          case MONTH:
            thisYearVals.add(new Entry(TypeUtil.getInt(listTimes.get(i).timerShaft),
                TypeUtil.parseFloat(listTimes.get(i).playTimes)));
            break;
          case YEAR:
            thisYearVals.add(new Entry(i + 1, TypeUtil.parseFloat(listTimes.get(i).playTimes)));
            break;
          default:
            thisYearVals.add(new Entry(i, TypeUtil.parseFloat(listTimes.get(i).playTimes)));
            lineNames.put(i + 1, listTimes.get(i).timerShaft);
            break;

        }
        listTimesMax.add(TypeUtil.getInt(listTimes.get(i).playTimes));
      }
    }
    if (null != listTimesLast && listTimesLast.size() > 0) {
      for (int i = 0; i < listTimesLast.size(); i++) {
        switch (dateType) {
          case CUR:
          case DAY:
          case WEEK:
          case MONTH:
            lastYearVals.add(new Entry(TypeUtil.getInt(listTimesLast.get(i).timerShaft),
                TypeUtil.parseFloat(listTimesLast.get(i).playTimes)));
            break;
          case YEAR:
            lastYearVals.add(new Entry(i + 1, TypeUtil.parseFloat(listTimesLast.get(i).playTimes)));
            break;
          default:
            lastYearVals.add(new Entry(i, TypeUtil.parseFloat(listTimesLast.get(i).playTimes)));
            lineNames.put(i + 1, listTimesLast.get(i).timerShaft);
            break;
        }
        listTimesMax.add(TypeUtil.getInt(listTimesLast.get(i).playTimes));
      }
    }

    switch (dateType) {
      case CUR:
      case DAY:
        timeType = "较前日";
        xLableCount = 12;
        xMin = 2;
        xMax = 24;
        break;
      case WEEK:
        timeType = "较上周";
        xLableCount = 7;
        xMin = 1;
        xMax = 7;
        break;
      case MONTH:
        timeType = "较上月";
        xLableCount = 10;
        xMin = 3;
        xMax = 30;
        break;
      case QUARTER:
        timeType = "较上季";
        xLableCount = 6;
        xMin = 1;
        xMax = 6;
        break;
      case YEAR:
        timeType = "较上年";
        xLableCount = 12;
        xMin = 1;
        xMax = 12;
        break;
      default:
        break;
    }
    listCaddieThis.clear();
    listCaddieLast.clear();
    listNameId.clear();
    if (!Util.listIsNull(listBarThis)) {
      ListBean bean;
      for (int i = 0; i < listBarThis.size(); i++) {
        thisYearPawWayVals.add(new BarEntry(i, (!Util.isNull(listBarThis.get(i).playTimes)
            && Util.isDouble(listBarThis.get(i).playTimes)) ? Float
            .parseFloat(listBarThis.get(i).playTimes) : 0));
        payNameMap.put(startStep + i, Util.isNull(listBarThis.get(i).levelName) ?
            "" : listBarThis.get(i).levelName + "级");
        idMap.put(startStep + i, listBarThis.get(i).levelId);
        if (null != listBarThis.get(i).caddieHistograms) {
          listCaddieThis.addAll(listBarThis.get(i).caddieHistograms);
        }
        bean = new ListBean();
        bean.idForName = listBarThis.get(i).levelId;
        bean.nameForShow = listBarThis.get(i).levelName + "级";
        listNameId.add(bean);
        try {
          listLevelMax.add((int) Float.parseFloat(listBarThis.get(i).playTimes));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
    if (!Util.listIsNull(listBarLast)) {
      for (int i = 0; i < listBarLast.size(); i++) {
        lastYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarLast.get(i).playTimes)));
        if (payNameMap.isEmpty()) {
          payNameMap.put(startStep + i, Util.isNull(listBarLast.get(i).levelName) ?
              "" : listBarLast.get(i).levelName + "级");
        }
        if (null != listBarLast.get(i).caddieHistograms) {
          listCaddieLast.addAll(listBarLast.get(i).caddieHistograms);
        }
        try {
          listLevelMax.add((int) Float.parseFloat(listBarLast.get(i).playTimes));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
    if (listTimesMax.size() > 0) {
      lineLeftMax = Collections.max(listTimesMax);
    }
    if (listLevelMax.size() > 0) {
      barLeftMax = Collections.max(listLevelMax);
    }
    setCaddieCallBack();
  }

  String timeType = "较前日";

  private void setCaddieCallBack() {

    allCompare = timeType + TextUtil.getDoubleFormat(allTimesCompare, 2) + "%";
    InCompare = timeType + TextUtil.getDoubleFormat(timesCompare, 2) + "%";
    noCludeCompare = timeType + TextUtil.getDoubleFormat(durationCompare, 2) + "%";
    ChartBean bean = new ChartBean();
    bean.allNum = TypeUtil.parseFloat(TextUtil.getDoubleFormat(allTimes, 2));
    bean.inNum = TypeUtil.parseFloat(TextUtil.getDoubleFormat(meanTimes, 2));
    bean.noCludeNum = TypeUtil.parseFloat(TextUtil.getDoubleFormat(meanDuration, 2));
    bean.allRatio = allCompare;
    bean.inRatio = InCompare;
    bean.noCludeRatio = noCludeCompare;

    bean.lineLeftMax = lineLeftMax < 10 ? 12 : (int) lineLeftMax;
    bean.lineXLableCount = xLableCount;
    bean.lineYLableCount = 7;
    bean.lineXMax = xMax;
    bean.lineXMin = xMin;

    bean.barYLableCount = 7;
    bean.barLeftMax = barLeftMax < 10 ? 12 : (int) barLeftMax;

    bean.BarthisVals = thisYearPawWayVals;
    bean.BarlastVals = lastYearPawWayVals;
    bean.BarMap = payNameMap;
    bean.barXLableCount =
        !Util.listIsNull(listBarLast) ? listBarLast.size() : 0;
    bean.LinethisVals = thisYearVals;
    bean.LinelastVals = lastYearVals;
    bean.dateType = dateType;
    bean.lineNames = lineNames;
    bean.listCaddieThis = listCaddieThis;
    bean.listCaddieLast = listCaddieLast;
    bean.listNameId = listNameId;
    bean.endTime = endTime;
    bean.startTime = startTime;
    worker.getDataSuccess(bean);


  }


  @Override
  public void getBussinessData(StatisticsBean m) {
    if (null != m.outletTotalDto) {
      allNum = TypeUtil.parseFloat(m.outletTotalDto.total);
      inCludeNum = TypeUtil.parseFloat(m.outletTotalDto.income);
      noCludeNum = TypeUtil.parseFloat(m.outletTotalDto.nonrevenue);

      allCompare = m.outletTotalDto.compareTatalPercent;
      InCompare = m.outletTotalDto.compareIncomePercent;
      noCludeCompare = m.outletTotalDto.compareNonrevenuePercent;

      lastMoneyMax = m.outletTotalDto.maxLastTimePay;
      thisMoneyMax = m.outletTotalDto.maxTimePay;
      lastWayMax = m.outletTotalDto.maxLastPayWay;
      thisWayMax = m.outletTotalDto.maxPayWay;

    }
    listOutlet = m.outletTimePayDtos;
    listBarData = m.outletPayWayDtos;
    thisYearVals.clear();
    lastYearVals.clear();
    if (null != listOutlet && listOutlet.size() > 0) {
      for (int i = 0; i < listOutlet.size(); i++) {
        switch (dateType) {
          case WEEK:
          case QUARTER:
            thisYearVals.add(new Entry(listOutlet.get(i).x + 1, listOutlet.get(i).y));
            lastYearVals.add(new Entry(listOutlet.get(i).x + 1, listOutlet.get(i).lastY));
            break;
          case MONTH:
            thisYearVals.add(new Entry(listOutlet.get(i).x + 2, listOutlet.get(i).y));
            lastYearVals.add(new Entry(listOutlet.get(i).x + 2, listOutlet.get(i).lastY));
            break;
          case CUR:
          case DAY:
          case YEAR:
            thisYearVals.add(new Entry(listOutlet.get(i).x, listOutlet.get(i).y));
            lastYearVals.add(new Entry(listOutlet.get(i).x, listOutlet.get(i).lastY));
            break;
          default:
            thisYearVals.add(new Entry(i, listOutlet.get(i).y));
            lastYearVals.add(new Entry(i, listOutlet.get(i).lastY));
            break;
        }

      }
    }
    thisYearPawWayVals.clear();
    lastYearPawWayVals.clear();
    payNameMap.clear();
    if (!Util.listIsNull(listBarData)) {
      for (int i = 0; i < listBarData.size(); i++) {
        thisYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).y)));
        lastYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).lastY)));
        payNameMap.put(startStep + i, Util.isNull(listBarData.get(i).lastX) ?
            Util.isNull(listBarData.get(i).x) ? "" : listBarData.get(i).x
            : listBarData.get(i).lastX);
        idMap.put(startStep + i, TextUtil.Text(listBarData.get(i).xcode));
      }
    }
    setCallBackData();
  }

  @Override
  protected void getBookData(StatisticsBean m) {
    if (null != m.reserveTotalDto) {
      allNum = m.reserveTotalDto.total;
      inCludeNum = m.reserveTotalDto.come;
      noCludeNum = m.reserveTotalDto.nocome;

      allCompare = m.reserveTotalDto.compareTatalPercent;
      InCompare = m.reserveTotalDto.compareComePercent;
      noCludeCompare = m.reserveTotalDto.compareNocomnePercent;

      lastMoneyMax = m.reserveTotalDto.maxLastReserveCount;
      thisMoneyMax = m.reserveTotalDto.maxReserveCount;
      lastWayMax = m.reserveTotalDto.maxLastLine;
      thisWayMax = m.reserveTotalDto.maxLine;

    }
    listBarData = m.reserveLineDtos;
    listLineData = m.reserveTimeDtos;
    if (!Util.listIsNull(listLineData)) {
      for (int i = 0; i < listLineData.size(); i++) {
        switch (dateType) {
          case WEEK:
          case QUARTER:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x) + 1,
                TypeUtil.parseFloat(listLineData.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x) + 1,
                TypeUtil.parseFloat(listLineData.get(i).lastY)));
            break;
          case MONTH:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x) + 2,
                TypeUtil.parseFloat(listLineData.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x) + 2,
                TypeUtil.parseFloat(listLineData.get(i).lastY)));
            break;
          case CUR:
          case DAY:
          case YEAR:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x),
                TypeUtil.parseFloat(listLineData.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listLineData.get(i).x),
                TypeUtil.parseFloat(listLineData.get(i).lastY)));
            break;
          default:
            thisYearVals.add(new Entry(i, TypeUtil.parseFloat(listLineData.get(i).y)));
            lastYearVals.add(new Entry(i, TypeUtil.parseFloat(listLineData.get(i).lastY)));
            break;
        }


      }
    }
    if (!Util.listIsNull(listBarData)) {
      for (int i = 0; i < listBarData.size(); i++) {
        thisYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).y)));
        lastYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).lastY)));
        payNameMap
            .put(startStep + i, Util.isNull(listBarData.get(i).x) ? "" : listBarData.get(i).x);
      }
    }
    setCallBackData();
  }

  private List<StatisticsBean.Line> lineThis = new ArrayList<>();
  private List<StatisticsBean.Line> lineLast = new ArrayList<>();
  private List<StatisticsBean.Bar> BarThis = new ArrayList<>();
  private List<StatisticsBean.Bar> BarLast = new ArrayList<>();

  @Override
  public void getBillData(StatisticsBean m) {
    if (null != m.listDto) {
      allNum = (null != m.listDto.first) ?
          TypeUtil.parseFloat(TextUtil.getDoubleFormat(m.listDto.first.totalSigningFee,
              2))
          : 0;
      inCludeNum = (null != m.listDto.second) ?
          TypeUtil.parseFloat(
              TextUtil.getDoubleFormat(m.listDto.second.totalSigningFee, 2))
          : 0;
      noCludeNum = (null != m.listDto.third) ?
          TypeUtil.parseFloat(
              TextUtil.getDoubleFormat(m.listDto.third.totalSigningFee, 2))
          : 0;
      allCompare = (null != m.listDto.first) ? (
          (TypeUtil.parseFloat(m.listDto.first.lastTotalSigningFee) != 0 ?
              TextUtil.getDoubleFormat(String.valueOf(
                  TypeUtil.parseFloat(m.listDto.first.totalSigningFee)
                      / TypeUtil.parseFloat(m.listDto.first.lastTotalSigningFee) * 100)
                  + "", 2)
              : 0) + "%")
          : "0%";
      InCompare = (null != m.listDto.second) ? (
          (TypeUtil.parseFloat(m.listDto.second.lastTotalSigningFee) != 0 ?
              TextUtil.getDoubleFormat(String.valueOf(
                  TypeUtil.parseFloat(m.listDto.second.totalSigningFee)
                      / TypeUtil.parseFloat(m.listDto.second.lastTotalSigningFee) * 100), 2)
              : 0) + "%")
          : "0%";
      noCludeCompare = (null != m.listDto.third) ? (
          (TypeUtil.parseFloat(m.listDto.third.lastTotalSigningFee) != 0 ?
              TextUtil.getDoubleFormat(String.valueOf(
                  TypeUtil.parseFloat(m.listDto.third.totalSigningFee)
                      / TypeUtil.parseFloat(m.listDto.third.lastTotalSigningFee) * 100), 2)
              : 0) + "%")
          : "0%";
    }
    lineThis = m.curveList;
    lineLast = m.lastCurveList;
    thisYearVals.clear();
    lastYearVals.clear();
    getBillLine(lineThis, true);
    getBillLine(lineLast, false);

    BarThis = m.histogramList;
    BarLast = m.lastHistogramList;
    thisYearPawWayVals.clear();
    lastYearPawWayVals.clear();
    payNameMap.clear();
    listUserIds.clear();
    nameIdMap.clear();
    idMap.clear();
//    int max = getMaxBarSize(BarThis, BarLast);
//    if (max > 0) {
//      getBillBar(BarThis, true, max);
//      getBillBar(BarLast, false, max);
//    }
    getBillBar(BarThis, true);
    getBillBar(BarLast, false);
    setCallBackData();
  }

  private List<StatisticsBean.Bar> getMaxBarSize(List<StatisticsBean.Bar> barThis,
      List<StatisticsBean.Bar> barLast) {
    if (!Util.listIsNull(barThis) && !Util.listIsNull(barLast)) {
      if (barThis.size() > barLast.size()) {
        return barThis;
      }
      return barLast;
    }
    if (Util.listIsNull(barLast)) {
      return barThis;
    }
    return barLast;
  }


  private void getBillBar(List<StatisticsBean.Bar> list, boolean isThis) {
    if (!Util.listIsNull(list)) {
      for (int i = 0; i < list.size(); i++) {
        if (isThis) {
          thisYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(list.get(i).signingFee)));
        } else {
          lastYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(list.get(i).signingFee)));
        }
        if (!Util.isNull(list.get(i).signingId) && !listUserIds.contains(list.get(i).signingId)) {
          listUserIds.add(TextUtil.Text(list.get(i).signingId));
        }
        payNameMap.put(startStep + i, TextUtil.Text(list.get(i).signingName));
        nameIdMap.put(list.get(i).signingName, list.get(i).signingId);
        if (!Util.isNull(list.get(i).signingId) && !listBarData.contains(list.get(i).signingId)) {
          listUserIds.add(TextUtil.Text(list.get(i).signingId));
        }
        idMap.put(startStep + i, TextUtil.Text(list.get(i).signingId));
      }
    }
//    if (!Util.listIsNull(list)) {
//      int index = 0;
//      boolean has = false;
//      for (int i = 0; i < list.size(); i++) {
//        if (!CollectionUtil.mapIsNull(payNameMap)) {
//          for (int j = 0; j < payNameMap.size(); j++) {
//            if (Util.isEquals(CollectionUtil.getMapString(payNameMap, startStep + j),
//                list.get(i).signingName)) {
//              index = j;
//              has = true;
//              break;
//            }
//          }
//        }
//        if (has) {
//          if (isThis) {
//            thisYearPawWayVals
//                .add(new BarEntry(index, TypeUtil.parseFloat(list.get(i).signingFee)));
//          } else {
//            lastYearPawWayVals
//                .add(new BarEntry(index, TypeUtil.parseFloat(list.get(i).signingFee)));
//          }
//          payNameMap.put(startStep + index, TextUtil.Text(list.get(i).signingName));
//        } else {
//          if (isThis) {
//            thisYearPawWayVals
//                .add(new BarEntry(i, TypeUtil.parseFloat(list.get(i).signingFee)));
//          } else {
//            lastYearPawWayVals
//                .add(new BarEntry(i, TypeUtil.parseFloat(list.get(i).signingFee)));
//          }
//          payNameMap.put(startStep + i, TextUtil.Text(list.get(i).signingName));
//
//        }
//        nameIdMap.put(list.get(i).signingName, list.get(i).signingId);
//        if (!Util.isNull(list.get(i).signingId) && !listBarData.contains(list.get(i).signingId)) {
//          listUserIds.add(TextUtil.Text(list.get(i).signingId));
//        }
//        idMap.put(startStep + i, TextUtil.Text(list.get(i).signingId));
//      }
//      if (!CollectionUtil.mapIsNull(nameIdMap)) {
//        payNameMap.clear();
//        int inx = 0;
//        for (Map.Entry<String, String> me : nameIdMap.entrySet()) {
//          payNameMap.put(startStep + inx, me.getKey());
//          inx++;
//        }
//
//      }
//    }
  }

  private void getBillLine(List<StatisticsBean.Line> list, boolean isThis) {
    if (!Util.listIsNull(list)) {
      for (int i = 0; i < list.size(); i++) {
        if (isThis) {
          thisYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
              TypeUtil.parseFloat(list.get(i).fee)));
        } else {
          lastYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
              TypeUtil.parseFloat(list.get(i).fee)));
        }
//                switch (dateType) {
//                    case WEEK:
//                        if (isThis)
//                            thisYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        else
//                            lastYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        break;
//                    case MONTH:
//                        if (isThis)
//                            thisYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        else
//                            lastYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        break;
//                    case CUR:
//                    case DAY:
//                    case YEAR:
//                        if (isThis)
//                            thisYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        else
//                            lastYearVals.add(new Entry(TypeUtil.getInt(list.get(i).timerShaft),
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        break;
//                    default:
//                        if (isThis)
//                            thisYearVals.add(new Entry(i,
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        else
//                            lastYearVals.add(new Entry(i,
//                                    TypeUtil.parseFloat(list.get(i).fee)));
//                        break;
//                }

      }
    }
  }

  @Override
  protected void covertPlayerData(StatisticsBean m) {
    if (null != m.customerDto) {
      allNum = TypeUtil.parseFloat(m.customerDto.totalCount);
      inCludeNum = TypeUtil.parseFloat(m.customerDto.playCount);
      noCludeNum = TypeUtil.parseFloat(m.customerDto.noPlayCount);

      allCompare = m.customerDto.compareTotalPercent;
      InCompare = m.customerDto.comparePlayPercent;
      noCludeCompare = m.customerDto.compareNoPlayCountPercent;

//      lastMoneyMax = m.reserveTotalDto.maxLastReserveCount;
//      thisMoneyMax = m.reserveTotalDto.maxReserveCount;
//      lastWayMax = m.reserveTotalDto.maxLastLine;
//      thisWayMax = m.reserveTotalDto.maxLine;
    }
    listPlayerLine = m.customerComeDtoList;
    listBarData = m.customerIdentifyDtoList;
    if (!Util.listIsNull(listPlayerLine)) {
      for (int i = 0; i < listPlayerLine.size(); i++) {
        switch (dateType) {
          case WEEK:
          case QUARTER:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x) + 1,
                TypeUtil.parseFloat(listPlayerLine.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x) + 1,
                TypeUtil.parseFloat(listPlayerLine.get(i).lastY)));
            break;
          case MONTH:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x) + 2,
                TypeUtil.parseFloat(listPlayerLine.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x) + 2,
                TypeUtil.parseFloat(listPlayerLine.get(i).lastY)));
            break;
          case CUR:
          case DAY:
          case YEAR:
            thisYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x),
                TypeUtil.parseFloat(listPlayerLine.get(i).y)));
            lastYearVals.add(new Entry(TypeUtil.parseFloat(listPlayerLine.get(i).x),
                TypeUtil.parseFloat(listPlayerLine.get(i).lastY)));
            break;
          default:
            thisYearVals.add(new Entry(i, TypeUtil.parseFloat(listPlayerLine.get(i).y)));
            lastYearVals.add(new Entry(i, TypeUtil.parseFloat(listPlayerLine.get(i).lastY)));
            break;
        }


      }
    }
    if (!Util.listIsNull(listBarData)) {
      for (int i = 0; i < listBarData.size(); i++) {
        thisYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).y)));
        lastYearPawWayVals.add(new BarEntry(i, TypeUtil.parseFloat(listBarData.get(i).lastY)));
        payNameMap
            .put(startStep + i, Util.isNull(listBarData.get(i).x) ? "" : listBarData.get(i).x);
        idMap.put(startStep + i, TextUtil.Text(listBarData.get(i).xid));
      }
    }
    setCallBackData();
  }
}
